 <%@ page language="java" import="java.util.*" pageEncoding="utf-8" import="pojo.*,base.*,service.*,java.text.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <style type="text/css">

#all a {
           text-decoration:none;
           color:black;
           }

#all a:link,.toptext a:visited{color:black;}
#all a:hover{color:#A020F0;}  


img{border:none;}
 body{
	margin:0;
	padding:40px;
	background-image:url("images/bj.jpg");
	background-repeat:no-repeat;
	font:80% Arial, Helvetica, sans-serif;
	color:#555;
	line-height:100%;
}  
#tooltip{
	position:absolute;
	border:1px solid #ccc;
	background:#333;
	padding:2px;
	display:none;
	color:#fff;
}
   
 .STYLE1 {font-size: 100%
          }
  </style>
 <script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.7.2.min.js"></script>
 <script>
 function deleteTable(url){
  if(deleteconfirm()){
  location.href=url;
  }
 }
 function deleteconfirm(){
	if(confirm("确认要删除数据吗"))
		return true;
	return false;
 }
 function openpage(){
 	var page=$("#pagenum").val();
 	location.href="tablelistlist.jsp?pageno="+page;
 }

 </script>
<script language="javascript">
function unload()
{
var popUpSizeX=600; //窗口的宽度
var popUpSizeY=500; //窗口的高度

var popUpLocationX=700;//距离左边的距离 相当于 left
var popUpLocationY=300;//距离顶端的距离 相当于 top

// URL of the popUp
var popUpURL="TableType.jsp"; //打开页面的路径

// ** 下面的就不要随便改了 ***
splashWin = window.open("",'x','fullscreen=1,scrollbars=yes,resizable=0,toolbar=no, menubar=no,');
splashWin.blur(); // Hide while updating
window.focus();
splashWin.resizeTo(popUpSizeX,popUpSizeY);
splashWin.moveTo(popUpLocationX,popUpLocationY);
splashWin.location=popUpURL;
}

</script> 
  </head>
  
  <body>
   <div id="all">
     <div align="right"><a href="addTable.jsp" class="STYLE1" >添加餐桌</a><br/><br/>
                        <a href="#" onclick="unload()">餐桌种类</a>
     
     </div>
     <div id="list">
<%
	request.setCharacterEncoding("utf-8");
    String spageno = request.getParameter("pageno");
    String key = request.getParameter("key");
    int pageno;//页码
    int pagesize=8;//每页显示行数
    String where=" where 1= 1";           
	if(request.getParameter("type")!=null&&(Integer.parseInt(request.getParameter("type"))!=0)){
   where+=" and type="+Integer.parseInt(request.getParameter("type"));
    }
   if(request.getParameter("area")!=null&&(Integer.parseInt(request.getParameter("area"))!=0)){
   where+=" and area="+Integer.parseInt(request.getParameter("area"));
    } 
  ;
    if(spageno==null){ pageno = 1;}//当页码为空时默认为1
    
    else pageno=Integer.valueOf(request.getParameter("pageno"));//否则为传过来的页码
   TableService us = new TableService();
    int size=us.getALL(where);//获取总数量
	try{pageno = Integer.parseInt(spageno);}
	catch(Exception e){}
	Page p1=new Page();
								p1.setTotalRecord(size);
								p1.setCurrentPageNo(pageno);
								p1.setPageSize(pagesize);
		out.println("共有"+size+"个餐桌");	
	List<table> list = us.getTable(pageno,pagesize,where);//按参数查询
		  
		
	
			
%>
 
</div>

<form  action="tablelist.jsp" method="post">
  <div align="center">
    <select style="width:100px;" name="area"/>
    <option value=0>--请选择--</option>
    <option value=1>大厅</option>
    <option value=2>包厢</option>
    </select>
    <select style="width:200px;" name="type"/>
     <option value=0>--请选择--</option>
    <%	
	                           List<TableType> list1 = us.getTableType();
	                           for(TableType d:list1){
		                      
			                     out.print("<option value='"+d.getId()+"'>"+d.getName()+"</option>");
	                           } %>
    
    
   </select>
   <input type="submit" value="查询"/>
  </div>
</form>
<center>

	<table width="900" border="1">
      <tr>
        <td width="70"><div align="center">餐桌类型</div></td>
        <td width="50"><div align="center">餐桌类别</div></td>
        <td width="100"><div align="center">餐桌名 </div></td>
        <td width="100"><div align="center"> 备注</div></td>
         <td width="70"><div align="center"> 操作</div></td>
        
        
      </tr>
<%
    
	for (table inf : list) {
	int r=inf.getArea();
	if(r==1){
	out.println("<tr><td><div align='center'>大厅</div></td>");
	}
	else out.println("<tr><td><div align='center'>包厢</div></td>");
	out.println("<td><div align='center'>"+us.getType(inf.getType()).getName()+"</div></td>");
	out.println("<td><div align='center'>"+inf.getName()+"</div></td>");
	out.println("<td><div align='center'>"+inf.getDetail()+"</div></td>");
	out.println("<td><div align='center'><a href='updateTableInfor.jsp?id="+inf.getId()+"'>修改 </a><input type='button' onclick=deleteTable('action/deleteTable.jsp?id="+inf.getId()+"'); value='删除'/></div></td></tr>");
	}
	%>
	<%
	 out.print("<tr><td align='right' colspan='9'><h5>共"+p1.getTotalPage()+"页，当前第"+pageno+"页， ---<a href='tablelist.jsp?&pageno="+p1.getPrePage()+"'>上一页</a>");
								 out.print("<a href='tablelist.jsp?&pageno="+p1.getNextPage()+"'>下一页</a><input type=text name=pagenum id=pagenum style=width:20;border:1px solid grey> <a href='javascript:void(0);' onclick=openpage();>跳转</a></h5></td></tr>");
								 
%>
	
</table>
  </center>
 
  </div>
	
  </body>
</html>
